home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 7: Sunsite / Linux Cubed Series 7 - Sunsite Vol 1.iso / libs / winlib-0.0 / winlib-0 / win / sound.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-12-25  |  2.1 KB  |  83 lines

  1. /*
  2.  * WinLIB
  3.  * Sound support
  4.  */
  5.  
  6. #include <sys/types.h>
  7. #include <sys/stat.h>
  8. #include <string.h>
  9. #include <fcntl.h>
  10. #include <unistd.h>
  11. #include <stdlib.h>
  12. #include "winlib.h"
  13. #include "internal.h"
  14. #include "config.h"
  15.  
  16. char *_open_sound, *_close_sound, *_destroy_sound, *_min_sound, *_max_sound,
  17.      *_start_sound, *_exit_sound, *_menudrop_sound, *_menusel_sound;
  18.  
  19. void Win_SetSound(int type, char *f)
  20. {
  21. #ifdef    SOUND_SUPPORT
  22.     switch(type) {
  23.     case SOUND_OPEN:    _open_sound = (char *) malloc(strlen(f));
  24.                 strcpy(_open_sound, f);
  25.                 break;
  26.     case SOUND_CLOSE:    _close_sound = (char *) malloc(strlen(f));
  27.                 strcpy(_close_sound, f);
  28.                 break;
  29.     case SOUND_DESTROY:    _destroy_sound = (char *) malloc(strlen(f));
  30.                 strcpy(_destroy_sound, f);
  31.                 break;
  32.     case SOUND_MINIMIZE:    _min_sound = (char *) malloc(strlen(f));
  33.                 strcpy(_min_sound, f);
  34.                 break;
  35.     case SOUND_MAXIMIZE:    _max_sound = (char *) malloc(strlen(f));
  36.                 strcpy(_max_sound, f);
  37.                 break;
  38.     case SOUND_START:    _start_sound = (char *) malloc(strlen(f));
  39.                 strcpy(_start_sound, f);
  40.                 break;
  41.     case SOUND_EXIT:    _exit_sound = (char *) malloc(strlen(f));
  42.                 strcpy(_exit_sound, f);
  43.                 break;
  44.     case SOUND_MENUDROP:    _menudrop_sound = (char *) malloc(strlen(f));
  45.                 strcpy(_menudrop_sound, f);
  46.                 break;
  47.     case SOUND_MENUSEL:    _menusel_sound = (char *) malloc(strlen(f));
  48.                 strcpy(_menusel_sound, f);
  49.                 break;
  50.     }
  51. #endif
  52. }
  53.  
  54. void _play_sound(char *snd)
  55. {
  56. #ifdef    SOUND_SUPPORT
  57.     if (_sound_init) {
  58.     char fn[160];
  59.  
  60.     bzero(fn, 160);
  61.     sprintf(fn, "P%s\r\n", snd);
  62.     write(_sound_socket, fn, strlen(fn));
  63.     }
  64. #endif
  65. }
  66.  
  67. void Win_PlaySound(int type)
  68. {
  69. #ifdef    SOUND_SUPPORT
  70.     switch(type) {
  71.     case SOUND_OPEN:    _play_sound(_open_sound);    break;
  72.     case SOUND_CLOSE:    _play_sound(_close_sound);    break;
  73.     case SOUND_DESTROY:    _play_sound(_destroy_sound);    break;
  74.     case SOUND_MINIMIZE:    _play_sound(_min_sound);    break;
  75.     case SOUND_MAXIMIZE:    _play_sound(_max_sound);    break;
  76.     case SOUND_START:    _play_sound(_start_sound);    break;
  77.     case SOUND_EXIT:    _play_sound(_exit_sound);    break;
  78.     case SOUND_MENUDROP:    _play_sound(_menudrop_sound);    break;
  79.     case SOUND_MENUSEL:    _play_sound(_menusel_sound);    break;
  80.     }
  81. #endif
  82. }
  83.